package com.sky.controller.admin;

/**
 * @Author: yuking
 * @Date: 2025/9/16 - 09 - 16 - 21:31
 * @Description: com.sky.controller.admin
 * @version: 1.0
 */

import com.sky.dto.DishDTO;
import com.sky.dto.DishPageQueryDTO;
import com.sky.result.PageResult;
import com.sky.result.Result;
import com.sky.service.admin.DishService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/admin/dish")
@Api(tags = "菜品相关接口")
@Slf4j
public class DishController {
@Autowired
private DishService dishService;

@PostMapping
@ApiOperation("新增菜品")
public Result save(@RequestBody DishDTO dishDTO){
    log.info("新增菜品，参数为：{}",dishDTO);
    dishService.saveWithFlavor(dishDTO);
    return Result.success();
}
@GetMapping("/page")
@ApiOperation("菜品的分页查询")
public Result<PageResult> findByPage(DishPageQueryDTO dishPageQueryDTO){
    log.info("菜品分页查询，参数为:{}",dishPageQueryDTO);
    PageResult pageResult = dishService.findByPage(dishPageQueryDTO);
    return Result.success(pageResult);
}

@DeleteMapping
@ApiOperation("删除菜品")
public Result deleteByIds(@RequestParam List<Long> ids){
    log.info("菜品删除，参数为：",ids);
    dishService.deleteByIds(ids);
    return Result.success();
}
}
